<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>杀虫机</title>
    <!-- 引入Vuetify CSS -->
    <link href="/static_base/vuetify2.6.4.min.css" rel="stylesheet">
    <link href="/static_base/element_ui.css" rel="stylesheet">
    <link href="/insect/static_base/cq/iconfont.css" rel="stylesheet">
    <!-- 引入Material Design Icons -->
    <!-- <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.x/css/materialdesignicons.min.css" rel="stylesheet"> -->
    <!-- 引入Vue和Vuetify JS -->
    <script src="/static_base/vue2.6.14.js"></script>
    <script src="/static_base/element_ui_2.0.3_index.js"></script>
    <script src="/static_base/vuetify2.6.4.js"></script>
    <script type="text/javascript" src="/static_base\base.js"></script>
    <script type="text/javascript" src="/static_base\base_vue_template.js"></script>
    <script type="text/javascript" src="/static_base\js-md5.js"></script>
    <style>
        @media (max-width: 768px) {
    .el-message-box {
        width: 90%;
    }
}
.select_date div div div div div div{
    padding:0;
}
.select_date div div div div div div div input{border: 0px solid #DCDFE6!important;}
.el_select_page div div div div div div div ul{
    padding-left: 0px;
}
.el_select_page{
    
    margin-top: 20px;
}
.el_select_page div div div{
    box-shadow:none!important;
}
    </style>
</head>
<body>
    <div id="rr">
        <v-app>
            <v-main>
                <v-container>
                    <!-- 使用父组件 -->
                    <test-component></test-component>
                </v-container>
            </v-main>
        </v-app>
    </div>

    <script>
        // 创建Vuetify实例
        let vuetify = new Vuetify();

// 注册自定义的Vuetify子组件
Vue.component2('tabs2', {
    template: `
        <v-tabs show-arrows v-model='now_select' :key='refresh'>
                <v-tab  v-for="v,indexr in data.title_data.data" :key="'ttt_'+indexr">{{v}}</v-tab>
        </v-tabs>
    `,
        data(){
        return {
        refresh:'1',
        now_select:'0',
        data:{
            title_data:{
            data:[],
            callback:null
            }
        }
        }
        },
        watch:{
            "data.title_data":{
            handler(newValue) {  
                // console.log("刷新标题")
                this.refresh=this.refresh==='1' ?'2' : '1';
            },  
            deep: true, // 开启深度监听  }
        },
            "now_select":function(e){
                try{this.data.title_data.callback(e)}catch{}
        // console.log(this.now_select)
            }
        },
    
    mounted: function () {  
    window.ttt=this
    //测试
    this.data.title_data.data=['虫情测报','设备状态','设备控制'];
  }
        });

        // 注册自定义的非Vuetify子组件
        Vue.component2('custom-greeting', {
            template: `
                <div>
                    <h2>Welcome to our app!</h2>
                    <p>This is a custom greeting component.</p>
                </div>
            `,
        });

        // 注册自定义的Vuetify表格子组件
        Vue.component2('custom-table', {
            template: `
                <v-data-table
                    :headers="headers"
                    :items="desserts"
                    :items-per-page="5"
                    class="elevation-1"
                ></v-data-table>
            `,
            data() {
                return {
                    headers: [
                        { text: 'Dessert (100g serving)', value: 'name' },
                        { text: 'Calories', value: 'calories' },
                        { text: 'Fat (g)', value: 'fat' },
                        { text: 'Carbs (g)', value: 'carbs' },
                        { text: 'Protein (g)', value: 'protein' },
                        { text: 'Iron (%)', value: 'iron' },
                    ],
                    desserts: [
                        { name: 'Frozen Yogurt', calories: 159, fat: 6.0, carbs: 24, protein: 4.0, iron: '1%' },
                        { name: 'Ice cream sandwich', calories: 237, fat: 9.0, carbs: 37, protein: 4.3, iron: '1%' },
                        { name: 'Eclair', calories: 262, fat: 16.0, carbs: 23, protein: 6.0, iron: '7%' },
                        { name: 'Cupcake', calories: 305, fat: 3.7, carbs: 67, protein: 4.3, iron: '8%' },
                        { name: 'Gingerbread', calories: 356, fat: 16.0, carbs: 49, protein: 3.9, iron: '16%' },
                    ],
                };
            },
        }); // 定义菜单组件
        Vue.component2('a0_a1_a0_a4_a0', {
            template: `
<v-select
  label="当前设备ID"
  v-model="data.v"
 @change="select"
  :items="data.data"
></v-select>
            `,
            data: () => ({
                menu: false,
                data:{
                    v:'test1',
                    data:['test1','test2'],
                    select_id:null,//选择id的回调函数 由父组件传入
                }
            }),
            watch:{
                "data.v":function(e){
                    console.log(e);
                    try{this.data.select_id(e)}
                    catch{}

                }
            },
            methods: {
                toggleMenu() {
                    this.$refs.menu.open();
                },
                select(e){
                    console.log(e);
                    try{this.data.select_id(e)}
                    catch{}
                }
            },
            mounted:function(){
                _this.data.data=[];
            }
        });

        //a0_a1_a0_a1_a0 设备状态
Vue.component2('a0_a1_a0_a1_a0', {
  template: `
      <div>
        <v-card-text>
            <v-divider></v-divider>
            <p>工作状态: {{data.connect_status}}</p>
        </v-card-text>
      </div>
  `,
    data: () => ({
        data:{
        connect_status:"未连接"
    
    }
    }),
});

//a0_a1_a0_a0_a0 虫情测报
Vue.component2('a0_a1_a0_a0_a0', {
    template: `
    </div>
        <v-container>
            <div class="select_date" :key='timekey'>
                <v-row>
                    <v-col cols="12" sm="6" md="4" lg="3" >
                        <v-card class="mx-auto" max-width="300">
                            <v-card-text>
                                <v-row>
                                    <v-col cols="12">
    <div style="
    margin-left: 10px;
    margin-bottom: -4px;
">开始时间</div>

    <el-date-picker
    key='x1'
      v-model="value1"
      type="date"
       @change="handleDateChange1"  
      placeholder="选择查询开始日期">
    </el-date-picker>
                                    </v-col>
                                </v-row>
                            </v-card-text>
                        </v-card>
                    </v-col>
                                        <v-col cols="12" sm="6" md="4" lg="3" >
                        <v-card class="mx-auto" max-width="300">
                            <v-card-text>
                                <v-row>
                                    <v-col cols="12">
    <div style="
    margin-left: 10px;
    margin-bottom: -4px;
">结束时间</div>

    <el-date-picker
    key='x2'
      v-model="value2"
      type="date"
       @change="handleDateChange2"  
      placeholder="选择查询结束日期">
    </el-date-picker>
                                    </v-col>
                                </v-row>
                            </v-card-text>
                        </v-card>
                    </v-col>

                                        <v-col cols="12" sm="6" md="4" lg="3" >
                        <v-card class="mx-auto"  max-width="300">
                            <v-card-text>
                                <v-row>
                                    <v-col cols="12">
    <div style="
    margin-left: 10px;
    margin-bottom: -4px;
">快捷方式</div>
<div style="
height:40px;
    display: flex;
    justify-content: center;">
<v-btn style="margin-top:5px;margin-left:10px;" @click="set3">一月</v-btn>
<v-btn style="margin-top:5px;margin-left:10px;" @click="set2">一周</v-btn>
<v-btn style="margin-top:5px;margin-left:10px;" @click="set1">一天</v-btn>
</div>
                                    </v-col>
                                </v-row>
                            </v-card-text>
                        </v-card>
                    </v-col>
                </v-row>
                </div>


            <v-dialog v-model="dialog" max-width="800px">
                <v-card>
                    <v-img :src="selectedImage" alt="放大图片" max-height="600" contain></v-img>
                </v-card>
            </v-dialog>
                <v-row :refresh="refresh_val">
                    <v-col cols="12" sm="6" md="4" lg="3" v-for="card in data.items" :key="card.id">
                        <v-card class="mx-auto" max-width="300">
                            <v-card-text>
                                <v-row>
                                    <v-col cols="12">
                                        <h5 class="text-h6 mb-2">{{ card.date }}</h5>
                                    </v-col>
                                </v-row>
                                <v-row>
                                    <v-col cols="12">
                                        <v-img :src="card.image" @click="openDialog(card)" alt="示例图片" max-height="200" contain></v-img>
                                    </v-col>
                                </v-row>

                                <v-row>
                                    <v-col cols="12">
                                        <h5 class="text-h6 mb-2" :style="card.msg_color">{{ card.message }}</h5>
                                    </v-col>
                                </v-row>

                            </v-card-text>
                        </v-card>
                    </v-col>
                </v-row>

                    
            <div class="el_select_page">
                <v-row>
                    <v-col cols="12" sm="6" md="4" lg="3" >
                        <v-card class="mx-auto" max-width="300">
                            <v-card-text>
                                <v-row>
                                    <v-col cols="12">
      <el-pagination
      @current-change="handleCurrentChange"
  small
  layout="prev, pager, next"
  :total="total">
</el-pagination>
                                    </v-col>
                                </v-row>
                            </v-card-text>
                        </v-card>
                    </v-col>
                </v-row>
                </div>
        </v-container>
        
    </div>
    `,
  created() {  
            let res=this.getDateRange(30);
            // this.time1=this.value1=res.start;
            // this.time2=this.value2=res.end;
            // this.timekey =='timekeyx'?'timekey':'timekeyx';
  },  
    data: () => ({
        // test_message:"",
        request_type:1,
        total:0,//当前最大页码
        page_size:"10",//当前选择煤业显示数量
        value1:"",
        value2:"",
        time1:"",
        time2:"",
        timekey:'',
        start_time:"",
        callback_func:null,
        dialog:false,
        now_select_page:"1",//当前选择的页码
        refresh_val:"1",
        selectedImage:"",//当前选择的图片
        headers: [
            { text: '日期', value: 'date' },
            // { text: '名称', value: 'name' },
            { text: '图片', value: 'image' },
            // { text: '数量', value: 'quantity' }
        ],
        
        data:{
            token:'',
            did:'',
        items: [
            { date: '2023-09-27', name: 'Item 1', image: 'https://via.placeholder.com/50', quantity: 10 ,"message":"无"},
            { date: '2023-09-28', name: 'Item 2', image: 'https://via.placeholder.com/50', quantity: 20,"message":"无" },
            { date: '2023-09-29', name: 'Item 3', image: 'https://via.placeholder.com/50', quantity: 30 ,"message":"无"},
            { date: '2023-09-30', name: 'Item 4', image: 'https://via.placeholder.com/50', quantity: 40 ,"message":"无"}
        ]}
    }),
    watch:{

"data.token":function(e){
if (this.data.token && this.data.did &&this.request_type){
    this.request_type=0;
    this.request_5_picRecord_func(this.now_select_page)
}
},
"data.did":function(e){
if (this.data.token && this.data.did &&this.request_type){
    this.request_type=0;
    this.request_5_picRecord_func(this.now_select_page)
}
}


    },
    methods:{
        openDialog:function(card){
            this.selectedImage=card.image;
            this.dialog=true;
        },
        set1:function(){
            let res=this.getDateRange(1);
if (this.data.token && this.data.did &&this.init_val){
    this.request_5_picRecord_func(this.now_select_page);
}
        },
        set2:function(){
            let res=this.getDateRange(7);
if (this.data.token && this.data.did &&this.init_val){
    this.request_5_picRecord_func(this.now_select_page);
}
        },
        set3:function(){
            let res=this.getDateRange(30);
if (this.data.token && this.data.did &&this.init_val){
    this.request_5_picRecord_func(this.now_select_page);
}
        },
        formatDate2:function (date) {  
    let year = date.getFullYear();  
    let month = String(date.getMonth() + 1).padStart(2, '0');  
    let day = String(date.getDate()).padStart(2, '0');  
    return `${year}-${month}-${day}`;  
}  ,
  
getDateRange:function (daysAgo) {  
    let endDate = new Date();  
    let startDate = new Date(endDate);  
    endDate.setDate(endDate.getDate() +1);  
    startDate.setDate(startDate.getDate() - daysAgo);  
    let startDateStr = this.formatDate2(startDate);  
    let endDateStr = this.formatDate2(endDate);  
    this.time1=startDateStr+' 0:0:0';
    this.time2= endDateStr+' 23:59:59' ;
    this.value1=startDateStr;
    this.value2=endDateStr;
    this.timekey =='timekeyx'?'timekey':'timekeyx';
    return {  
        start: startDateStr+' 0:0:0',  
        end: endDateStr+' 23:59:59'  
    };  
    
}  ,
      handleCurrentChange(val) {
        this.now_select_page=val;
        console.log(`当前页: ${val}`);
if (this.data.token && this.data.did){
    this.request_5_picRecord_func(this.now_select_page)
}
      },
      formatDate:function (date) {  
  let year = date.getFullYear();  
  let month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要加1  
  let day = String(date.getDate()).padStart(2, '0');  
  let hours = date.getHours();  
  if (hours === 0 && date.getMinutes() === 0 && date.getSeconds() === 0 && date.getMilliseconds() === 0) {  
    // 如果是当天的开始时间（00:00:00.000），则加一天再减去1毫秒来模拟24:00:00（实际上为下一天的00:00:00前）  
    date = new Date(date.getTime() + 24 * 60 * 60 * 1000 - 1);  
    hours = date.getHours(); // 这将是下一天的0（即我们想要的"24:00:00"的等效表示的前一毫秒）  
  } else {  
    // 如果不是当天的开始时间，则简单地设置为23:59:59  
    hours = 23;  
    date.setHours(23, 59, 59, 0); // 直接设置时间部分  
  }  
    
  let hoursStr = String(hours).padStart(2, '0');  
  let minutes = String(date.getMinutes()).padStart(2, '0');  
  let seconds = String(date.getSeconds()).padStart(2, '0');  
    
  return `${year}-${month}-${day} ${hoursStr}:${minutes}:${seconds}`;  
}  ,
    handleDateChange1:function(change_val){
        this.time1=this.formatDate(change_val);
if (this.data.token && this.data.did ){

    this.request_5_picRecord_func(this.now_select_page);
    
}
    },
    
    handleDateChange2:function(change_val){
        this.time2=this.formatDate(change_val);
if (this.data.token && this.data.did &&this.init_val){
    this.request_5_picRecord_func(this.now_select_page);
}
    },
    setDefaultDateTime() {  
      let now = new Date();  
      let oneDayInMilliseconds = 24 * 60 * 60 * 1000;  
      let oneHundredDaysAgo = now - 100 * oneDayInMilliseconds;  
      let oneHundredDaysAgoDate = new Date(oneHundredDaysAgo);  
      this.start_time=this.value1 = oneHundredDaysAgoDate.toISOString().slice(0, 19).replace('T', ' ');  
      // 如果需要在创建时自动设置选择器的值，可以取消下面这行的注释  
      // this.dateTime = this.defaultDateTime;  
    }, replaceEnglishWithSpaces:function (str) {  
    // 使用正则表达式匹配所有英文字符（不区分大小写），并替换为空格  
    return (str+'').replace(/[a-zA-Z]/g, ' ');  
}  ,
    getday2() {  let now = new Date();
let oneDayInMilliseconds = 24 * 60 * 60 * 1000;
let oneHundredDaysAgo = new Date(now.getTime() +2 * oneDayInMilliseconds);
let oneHundredDaysAgoDate = new Date(oneHundredDaysAgo);
let value1 = oneHundredDaysAgoDate.toISOString().slice(0, 19).replace('T', ' ');

// console.log(value1);

      return value1
      // 如果需要在创建时自动设置选择器的值，可以取消下面这行的注释  
      // this.dateTime = this.defaultDateTime;  
    }, 
},
            mounted:function(){
                // _this.test_message+="1\n";
                // console.log('a0_a1_a0_a0_a0',_this.deepcopy_data)
                _this.data.items=[];
                
    _this.request_5_picRecord=request______({method:'post',url:'/insect/api/0/v0/picRecord'}),// /api/项目id/版本0/请求内容
    _this.update_picRecord=function(received_data){
        _this.init_val=true;
        // _this.test_message+="3\n";
// console.log("recvdata",received_data);
        if (received_data.status==0){

            _this.$message({
               type:"error" ,
               message:"获取用户历史数据失败"
            })
        }
        else{
            let items_=[];
            for (let i =0;i<received_data.data.length;i++){
        //         {
        //     "datetime": "2024-10-06 22:24:17",
        //     "ai_result": "[{\"num\":\"1\",\"name\":\"\u5bb3\u866b\"}]",
        //     "ai_result_num": "[{\"num\":\"1\",\"name\":\"\u5bb3\u866b\"}]",
        //     "thumb": "http://admin.wlwapp.cn/uploads/2024-10/0a60020924c1f525e4e5975708466edd.jpg",
        //     "ai_engine": "\u98de\u6d46V21",
        //     "source_thumb": "http://admin.wlwapp.cn/uploads/2024-10/1e074cda87c71a6e.jpg",
        //     "id": 34414.0,
        //     "did": "AAAA402A8FB24514",
        //     "url": "2024-10",
        //     "ai_status": 1.0
        // }    
                let msg='';
                let msg_color='';
                try{
                    let ai_result=JSON.parse(received_data.data[i].ai_result);
                    for (let jj=0;jj<ai_result.length;jj++){
                        msg=msg+ai_result[jj].name+ai_result[jj].num+'只;'
                    }
                }catch{}

                if(msg==''){
                    msg='无';
                    msg_color='color: rgb(6, 214, 160);'
                }else{
                    msg_color='color: rgb(239, 71, 111);'
                }

                items_.push(
                        {
                            "date":received_data.data[i].datetime,
                            "image":received_data.data[i].thumb,
                            "message":msg,
                            "msg_color":msg_color
                        }
                    );
            }
            _this.data.items=items_;
            _this.total=received_data.count;
            _this.refresh_val=_this.refresh_val=='1'?"2":"1";//刷新组件
        } 
        // _this.test_message+="2\n";

    }

    
    //切换到图片 获取历史图片
    
    _this.request_5_picRecord_func=function(pages="1"){
        // _this.test_message+="4\n";
        // console.log(_this.value1,"选择日期")
        // _this.test_message+="5\n";
        // _this.test_message+=`${_this.data.token}'token'\n`;
        // _this.test_message+=`${_this.data.did}'did'\n`;
        // _this.test_message+=`${_this.start_time}'start_time'\n`;
        // _this.test_message+=`${_this.getday2()}'getday2'\n`;
        // _this.test_message+=`${pages}'pages'\n`;
        let body_data={token:_this.data.token,

"did":_this.data.did,
"startTime":_this.time1,
"endTime":_this.time2,
"num":"10",
"pages":pages
}
// for (let kkk in body_data){

//     _this.test_message+=kkk;
//     _this.test_message+='=';
//     _this.test_message+=body_data[kkk];
//     _this.test_message+=',';
// }
// _this.test_message+='6';
        _this.request_5_picRecord({
        body_data:body_data,
        execute_lst:[
                {
                    type:'func',
                    func:_this.update_picRecord,
                    args:['received_data']
                }
            ]})
     }
     
        // lhp_deepcopy1(_this.data,_this.deepcopy_data);
            }
}
);


Vue.component2("card",
{
    template:`
                <v-card class="mx-auto" max-width="400">
                    <v-container>
                        <v-row>
                            <v-col cols="6" class="d-flex align-center">
                                <span class="mr-4">{{data.groupname}}</span>
                            </v-col>
                            <v-col v-if="data.list.length"cols="6" class="d-flex justify-end align-center" :key="refresh2">
                                <v-switch v-model="data.status=='开启'"label=""@change="onSwitchChange" ></v-switch>
                            </v-col>
                            
                            <div v-if="!data.list.length" class="d-flex justify-end align-center col col-6"><div class="v-input v-input--is-label-active v-input--is-dirty theme--light v-input--selection-controls v-input--switch primary--text"><div class="v-input__control"><div class="v-input__slot"><div class="v-input--selection-controls__input"><input aria-checked="true" id="input-311" role="switch" type="checkbox" aria-disabled="false" value=""></div></div><div class="v-messages theme--light primary--text"><div class="v-messages__wrapper"></div></div></div></div></div>
                            
                        </v-row>
                        <v-row style="align-items: center;display: flex;">
                            <v-col cols="4">
                                <v-divider></v-divider>
                            </v-col>
                            
                            <v-col cols="4"  style="align-items: center; display: flex;"
                                :key="refresh1"
                                >
                                <div
                                  :style="data.style_">
                                {{data.status}}
                                </div>
                            </v-col>
                            
                            <v-col cols="4" >
                                <v-divider></v-divider>
                            </v-col>
                        </v-row>
                    </v-container>
                </v-card>


    `,
    data: () => ({
        refresh1:"1",
        refresh2:"a3",
        data:{
            style_base:`
                                    background: #e1fcf7;
                                    border-radius: 4px;
                                    width: 100%;
                                    height: 100%;
                                    display: table-cell;
                                    text-align: center;
                                    vertical-align: middle;`,
            green:'color: rgb(6, 214, 160);',
            red:'color: rgb(239, 71, 111);',
            style_:``,
            status:'',
            groupname:'aaa',//开关名称
            list:[],//是否可以控制开关
            callback:"",//回调函数
        },
        refresh:'1',//刷新组件用
    }),
    watch:{
        "data.status":function(e){
            if(e=="关闭"){
                this.data.style_=this.data.style_base+this.data.red;
            }else{
                this.data.style_=this.data.style_base+this.data.green;

            }
            this.refresh1=this.refresh1=="2"?"1":"2";
        }
    },
    methods:{
        onSwitchChange:function(e){
            this.refresh2=this.refresh2=="a3"?"a2":"a3";
            try{
                this.data.callback(this.data.groupname,e)}
            catch{}
        }
    },
mounted:function(){
    window.eeee=this
    //刷新组件
    this.refresh=this.refresh=="2"?"1":"2";
}

}

)



Vue.component2("card2",
{
    template:`
             
<v-card class="mx-auto" max-width="400">
                    <v-card-text>
                        <v-row>
                            <v-col>
                                
                                <h5 class="mb-0"><span :class="data.class">{{data.show_name}}</span></h5>
                                <p class="text-h5 mb-0" style="color: #7171b5;">{{data.show_val}}</p>
                            </v-col>
                        </v-row>
                    </v-card-text>
                </v-card>


    `,
    data: () => ({
        data:{
           show_name:"",
           show_val:""
        },
        refresh:'1',//刷新组件用
    }),

}

)
//a0_a1_a0_a2_a0 设备控制
Vue.component2('a0_a1_a0_a2_a0', {
    template: `
    <div>
          <v-row :key="refresh">
                    <v-col cols="12" sm="6" md="4" lg="3" v-for="item,indexr in data.items" :key="'card_id_'+indexr" >
                   
    <card  :deepcopy_data="item">

                <!-- 弹窗组件 -->
                <v-dialog v-model="dialog" max-width="500px">
                    <v-card>
                        <v-card-title>确认操作</v-card-title>
                        <v-card-text>
                            你确定要执行此操作吗？
                        </v-card-text>
                        <v-card-actions>
                            <v-spacer></v-spacer>
                            <v-btn text @click="cancel">取消</v-btn>
                            <v-btn color="primary" @click="confirm">确定</v-btn>
                        </v-card-actions>
                    </v-card>
                </v-dialog>
    </card></v-col>
</v-row>
</div>
    `,
    data: () => ({
        request_8_op:request______({method:'post',url:'/insect/api/0/v0/op'}),
        dialog:false,
        refresh:"1",
        cmd_dct_init:false,
        data:{
            fast_idx_lst:{
                "运行模式":0,
                "诱虫灯":1,
                "吹虫风机":2,
                "雨虫挡板":3,
                '杀虫仓上挡板':4,
                '杀虫仓加热':5,
                '杀虫仓下挡板':6,
                '烘干仓加热':7,
                '烘干仓下挡板':8,
                '震动装置':9,
                '补光灯':10,
                '摄像头':11,
                '清扫装置':12,
            },
            status_dct:'',
            cmd_dct:'',
            items: [
          {
            groupname:'运行模式',
            status: '开启',
            // list:[{'opname': '手动', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsRkFGQkZBMDAwMDAwRkE='}, 
            //   {'opname': '自动', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsRkFGQkZBMDAwMTAwRkE='}]
          },
          {
            groupname:'诱虫灯',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMTIwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMTIwMjAwMDY='}]
          },
          {
            groupname:'吹虫风机',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDIwMTAwMDY='}, 
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDIwMjAwMDY='}]
          },
          {
            groupname:'雨虫挡板',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDMwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDMwMjAwMDY='}]
          },
          {
            groupname:'杀虫仓上挡板',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDQwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDQwMjAwMDY='}]
          },
          {
            groupname:'杀虫仓加热',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDUwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDUwMjAwMDY='}]
          },
          {
            groupname:'杀虫仓下挡板',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDYwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDYwMjAwMDY='}]
          },
          {
            groupname:'烘干仓加热',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDcwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDcwMjAwMDY='}]
          },
          {
            groupname:'烘干仓下挡板',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDgwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDgwMjAwMDY='}]
          },
          {
            groupname:'震动装置',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDkwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwNzAwMDkwMjAwMDY='}]
          },
          {
            groupname:'补光灯',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwODAwMDEwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwODAwMDEwMjAwMDY='}]
          },
          {
            groupname:'摄像头',
            status: '开启',
            // list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwODAwMDIwMTAwMDY='}]
          },
          {
            groupname:'清扫装置',
            status: '开启',
            list:[{'opname': '开启', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwODAwMDMwMTAwMDY='},
              {'opname': '关闭', 'cmd': 'M0j5A6yfN6D7A45cMcj9Ufx6MjAxMDUsMDEwODAwMDMwMjAwMDY='}]
          },

        ]
    }
    }),
    watch:{
        "data.status_dct":function(e){  
            // console.log("watch this",this)
            // console.log("watch status_ect")
        let new_val=JSON.parse(e);
        let idx=null;
        let new_items=JSON.parse(JSON.stringify(this.data.items))
      for(let key in new_val){
        // console.log("watch,",key,this.data.fast_idx_lst)
        idx=this.data.fast_idx_lst[key];
        new_items[idx].status=new_val[key];
        new_items[idx]['callback']=this.callback;
      }
    //   console.log("new_items:",new_items)
      this.data.items=new_items;
      this.refresh=this.refresh=="aa2"?"aa1":"aa2";
    },
    'data.cmd_dct':function(e){
        
// {
//     "msg": "\u64cd\u4f5c\u6210\u529f",
//     "data": [
//         {
//             "list": [
//                 {
//                     "opname": "\u624b\u52a8",
//                     "cmd": "M0j5A6yfN6D7E4wcMcD9gfw6OTQwMTcsRkFGQkZBMDAwMDAwRkE="
//                 },
//                 {
//                     "opname": "\u81ea\u52a8",
//                     "cmd": "M0j5A6yfN6D7E4wcMcD9gfw6OTQwMTcsRkFGQkZBMDAwMTAwRkE="
//                 }
//             ],
//             "groupname": "\u8fd0\u884c\u6a21\u5f0f"
//         },],
//     "status": 1
// }
        let new_val=JSON.parse(e);
        let new_dct={};
        for (let i=0;i<new_val.data.length;i++){
            new_dct[new_val.data[i].groupname]=new_val.data[i].list;
        }
        for (let key in this.data.fast_idx_lst){
            let item=this.data.items[this.data.fast_idx_lst[key]];
            if(item.list){
                for (let i=0;i<item.list.length;i++){
                    // console.log("new_dct",key,new_dct[key],new_dct[key])
                    let list=new_dct[key];
                    for(let j=0;j<list.length;j++){
                        if(list[j].opname==item.list[i].opname){
                            item.list[i].cmd=list[j].cmd;
                            continue;
                        }
                    }
                }
            }
        }
        // console.log("更新cmd完成");
        this.cmd_dct_init=true;
    }
    },
    methods:{cancel() {
                    this.dialog = false;
                    this.handleSelection(false);  // 传递取消的选择结果
                },
                confirm() {
                    this.dialog = false;
                    this.handleSelection(true);  // 传递确认的选择结果
                },
                handleSelection(selection) {
                    // 调用回调函数，处理选择结果
                    console.log('选择结果:', selection ? '确认' : '取消');
                    // 这里可以执行其他逻辑，例如发送请求等
                },
        callback:function(name,flag){
        let set_val='开启'
        if (flag==false){set_val='关闭'}
        this.$confirm('设置'+name+'为'+set_val, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        //   console.log("发起请求");
          if (this.cmd_dct_init==false){
            
            this.$message({"type":"error","message":"等待初始化cmd参数完成"});
            return;
          }
          let idx=this.data.fast_idx_lst[name];
          let idx2=set_val=="开启"?0:1;
          let groupname=this.data.items[idx].groupname;
          let cmd=this.data.items[idx].list[idx2].cmd;
          let opname=this.data.items[idx].list[idx2].opname;
          this.request_8_op_func(cmd,groupname,opname)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          });          
        });
        }
    },
    mounted:function(){
        window.pppp=_this;
        _this.status_dct='';
_this.return_callback_func=function(groupname,opname){
    return function(received_data){

if (received_data.status==0){
        _this.$message({"type":"error","message":"控制失败"})
    }else if(received_data.status==-1){
        _this.$message({"type":"error","message":"控制失败"})

    }
    else{
        // console.log(",groupname,opname",groupname,opname)
        // console.log("_this.data.fast_idx_lst[groupname]",_this.data.fast_idx_lst[groupname])
        _this.data.items[_this.data.fast_idx_lst[groupname]].status=opname;
        // console.log("_this.data.items[_this.data.fast_idx_lst[groupname]]",_this.data.items[_this.data.fast_idx_lst[groupname]])
        _this.refresh=_this.refresh=="aa2"?"aa1":"aa2";
        _this.$message({"type":"success","message":"控制成功"})
//             {
//     "msg": "操作成功",
//     "status": 1
// }
        // //获取到token 保存token
        // _this.token=received_data.data.token;
        // console.log("获取到token:",_this.token);
        // //开始获取设备列表
        // _this.request_2_device_func();
    }
}
}
_this.request_8_op_func=function(cmd,groupname,opname){
        _this.request_8_op({
            body_data:{token:_this.data.token,
"did":_this.data.did,
cmd:cmd,groupname:groupname,opname:opname
},
execute_lst:[
                {
                    type:'func',
                    func:_this.return_callback_func(groupname,opname),
                    args:['received_data']
                }
            ]
        })
    }
    }
});


//a0_a1_a0_a3_a0 设备数据
Vue.component2('a0_a1_a0_a3_a0', {
    template: `
    <div>
        
        <v-card-text  :key="refresh2">
            <v-divider></v-divider>
            <p>工作状态: <span :style='work_style'>{{data.connect_status}}</span></p>
        </v-card-text>
        
          <v-row :key="refresh">
                    <v-col cols="12" sm="6" md="4" lg="3" v-for="item,indexr in data.items" :key="'card_id2_'+indexr">
    <card2 :deepcopy_data="{'show_name':item.name,'show_val':item.value+item.unit,'class':item.class}">
    </card2>
</v-col>
</v-row>
</div>
    `,
    data: () => ({
        work_style:'',
        refresh:"aa1",
        refresh2:"aa3",
        data:{
            connect_status:"未连接",
            recv_str:"",
            items: [
{"unit":"℃","ename":"ins-Temp1","name":"杀虫仓温度","value":"21"},{"unit":"℃","ename":"ins-Temp2","name":"烘干仓温度","value":"22"},{"unit":"","ename":"ins-State","name":"降雨状态","value":"0"},{"unit":"Lux","ename":"ins-light","name":"光照度","value":"208"}]
    }
    }),
    
    watch:{
        "data.recv_str":function(e){  
        let new_val=JSON.parse(e);
        for (let kk=0;kk<new_val.length;kk++){
            if (new_val[kk].name=='杀虫仓温度'){
                new_val[kk].class="icon iconfont icon-wendu";
            }else if(new_val[kk].name=='烘干仓温度'){
                new_val[kk].class="icon iconfont icon-wendu";
            }else if(new_val[kk].name=='降雨状态'){
                new_val[kk].class="icon iconfont icon-jiangyuliang";
            }else if(new_val[kk].name=='光照度'){
                new_val[kk].class="icon iconfont icon-guangzhao";
            }
        }
        this.data.items=new_val;
        if(this.data.connect_status=='未连接'){this.work_style='color: rgb(239, 71, 111);'}else{
            this.work_style='color: rgb(6, 214, 160);'
        }
        this.refresh=this.refresh=="aa2"?"aa1":"aa2";
        this.refresh2=this.refresh2=="aa4"?"aa3":"aa4";
    },
    },
});

// <a0_a1_a0_a1_a0 v-if="now_select_lab=='1'" :key="a0_a1_a0_a1_a0_refresh" :deepcopy_data="a0_a1_a0_a1_a0_data" ></a0_a1_a0_a1_a0>
// 注册父组件
Vue.component2('test-component', {
    'text':`
    
    `,
    template: `
        <div :key="refresh">
            <a0_a1_a0_a4_a0 :key="a0_a1_a0_a4_a0_refresh" :deepcopy_data="select_deivce_id_data"></a0_a1_a0_a4_a0>
            <tabs2 :deepcopy_data="select_tab_data"></tabs2>
            <a0_a1_a0_a0_a0 v-if="now_select_lab=='0'" :key="a0_a1_a0_a0_a0_refresh" :deepcopy_data="a0_a1_a0_a0_a0_data"></a0_a1_a0_a0_a0>
            <a0_a1_a0_a3_a0 v-if="now_select_lab=='1'" :key="a0_a1_a0_a3_a0_refresh" :deepcopy_data="a0_a1_a0_a3_a0_data"></a0_a1_a0_a3_a0>
            <a0_a1_a0_a2_a0 v-if="now_select_lab=='2'" :key="a0_a1_a0_a2_a0_refresh" :deepcopy_data="a0_a1_a0_a2_a0_data"></a0_a1_a0_a2_a0>

        </div>
    `,
    data: () => ({now_select_did:null,//当前选择的did
        a0_a1_a0_a0_a0_refresh:"5",
        a0_a1_a0_a0_a0_data:{},
        a0_a1_a0_a1_a0_refresh:"7",
        a0_a1_a0_a1_a0_data:{},
        a0_a1_a0_a2_a0_refresh:"9",
        a0_a1_a0_a2_a0_data:{},
        a0_a1_a0_a3_a0_refresh:"11",
        a0_a1_a0_a3_a0_data:{},
        did_lst:[],//存放设备列表
        did_status:{},//存放设备连接状态
        now_select_did:null,
        token:null,//用户token 通过request_1_login获取
        refresh:'1',//刷新组件用
        a0_a1_a0_a4_a0_refresh:"1",
        select_deivce_id_data:{},//选择设备ID组件的传入参数
        select_tab_data:{},//选择标签组件的传入参数
        now_select_lab:0,//当前选择的标签页
        //request______ 由 base.js提供
        request_1_login:request______({method:'post',url:'/insect/api/0/v0/login'}),// /api/项目id/版本0/请求内容  
        request_2_device:request______({method:'post',url:'/insect/api/0/v0/device'}),// /api/项目id/版本0/请求内容
        request_3_data:request______({method:'post',url:'/insect/api/0/v0/data'}),// /api/项目id/版本0/请求内容
        request_4_picnow:request______({method:'post',url:'/insect/api/0/v0/picnow'}),// /api/项目id/版本0/请求内容
        // request_5_picRecord:request______({method:'post',url:'/insect/api/0/v0/picRecord'}),// /api/项目id/版本0/请求内容 //放置到组件中
        request_6_opnow:request______({method:'post',url:'/insect/api/0/v0/opnow'}),// /api/项目id/版本0/请求内容
        request_7_ctrl:request______({method:'post',url:'/insect/api/0/v0/ctrl'}),// /api/项目id/版本0/请求内容 
        // request_8_op:request______({method:'post',url:'/insect/api/0/v0/op'}),// /api/项目id/版本0/请求内容  //放置到组件中
    }),
    methods:{
        //切换标签页面
        select_lab:function(lab_idx){
            // console.log("当前选择的标签页索引:",lab_idx);
            this.now_select_lab=lab_idx;
            //刷新组件
            if(lab_idx=='0'){
                
        this.update_a0_a1_a0_a0_a0()
            }else if(lab_idx=="2"){
                // console.log("????322222")
                this.request_6_opnow_func()
            }else if (lab_idx=="1"){
                // console.log("????3333")
                this.request_3_data_func()
            }
            // this.refresh=this.refresh=="2"?"1":"2"
        },
    },
    watch:{
        // "now_select_lab":{

        // }
    },
mounted:function(){
    
    // # /login 登录认证 需要username和password【md5】
    // # /device 获取设备列表 需要token【登录认证获取】
    // # /data 获取设备实时数据 需要token和did【通过设备列表获取到设备did
    // # /picnow 获取最新照片 需要token和did【通过设备列表获取到设备did 
    // # /picRecord  获取历史数据 需要token、did、startTime【开始时间如:2022-11-28 09:54:12】、endTime【结束时间如:2025-05-31 09:54:12】
    // # /opnow 获取最新设备控制状态 需要token和did【通过设备列表获取到设备did
    // # /ctrl 获取设备控制参数 需要token和did【通过设备列表获取到设备did
    // # /op 控制设备 需要token和did【通过设备列表获取到设备did】、cmd【控制码 由获取设备控制参数得到】、groupname【控制的类型如：灯光】、opname【控制的状态如:打开】

    window.eeee=this;
    //选择设备ID组件的传入参数
    this.select_deivce_id_data={};
    //选择标签组件的传入参数
    this.select_tab_data={title_data:{"callback":_this.select_lab}}
    //刷新组件
    this.refresh=this.refresh=="2"?"1":"2";
    
    //选择设备id
    _this.select_id=function(device_id){
        // console.log("当前选择设备id:",device_id);
        if (!_this.did_lst){_this.now_select_lab='100'}
        else{_this.now_select_lab='0';
        //刷新历史数据
        _this.update_a0_a1_a0_a0_a0();
        //更新连接状态
        _this.now_select_did=device_id;
        // _this.a0_a1_a0_a1_a0_data={"connect_status":_this.did_status[device_id]}
        // _this.a0_a1_a0_a1_a0_refresh=_this.a0_a1_a0_a1_a0_refresh=='8'?"7":"8";//刷新组件
        }
    }
    //1-登录认证 
    _this.get_token=function(received_data){
        // console.log("获取到received_data:",received_data);
        if (received_data.status==0){
            _this.$message({"type":"error","message":"获取用户token失败"})
            console.log("获取用户token失败")
        }
        else{
            //获取到token 保存token
            _this.token=received_data.data.token;
            // console.log("获取到token:",_this.token);
            //开始获取设备列表
            _this.request_2_device_func();
        }
    }
    _this.request_1_login_func=function(username,password){
            let json_body={
                username:username,
                password:md5(password),/*md5函数由js-md.js提供*/
            }
            _this.request_1_login({
                body_data:json_body,
                execute_lst:[//请求成功后的回调
                            {
                            'type':'func',
                            'func':_this.get_token,
                            'args':['received_data'],  //将服务器返回参数转为对象然后将 对象.token 作为传参传入函数_this.get_token中
                            },
                            ]

            })
        }
    //获取控制命令参数
    _this.update_ctrl=function(received_data){
// console.log("获取到控制数据:",received_data)
_this.cmd_dct=JSON.stringify(received_data);
// {
//     "msg": "\u64cd\u4f5c\u6210\u529f",
//     "data": [
//         {
//             "list": [
//                 {
//                     "opname": "\u624b\u52a8",
//                     "cmd": "M0j5A6yfN6D7E4wcMcD9gfw6OTQwMTcsRkFGQkZBMDAwMDAwRkE="
//                 },
//                 {
//                     "opname": "\u81ea\u52a8",
//                     "cmd": "M0j5A6yfN6D7E4wcMcD9gfw6OTQwMTcsRkFGQkZBMDAwMTAwRkE="
//                 }
//             ],
//             "groupname": "\u8fd0\u884c\u6a21\u5f0f"
//         },],
//     "status": 1
// }
    }
    _this.request_7_ctrl_func=function(){
        _this.request_7_ctrl({
            body_data:{token:_this.token,did:_this.now_select_did},
            execute_lst:[
                {
                    type:'func',
                    func:_this.update_ctrl,
                    args:['received_data']
                }
            ]
        })
    }
    //2-获取设备列表
    //{'msg': '操作成功', 'data': [{'del_flag': '0', 'video_json': '', 'type': '虫情测报', 'update_date': '2024-09-07 11:55:33', 'create_by': '1', 'datetime': '2024-08-26', 'mysort': 0, 'sim': '无', 'name': '智慧虫情测报站', 'id': '6b1958bb81bf45bc979fe2700eeaf42d', 'create_date': '2024-09-07 11:55:32', 'update_by': 'd708920d37ac4c7cb3ccc0132f0a98e8', 'did': 'AAAA402A8FB24514', 'status': '已连接'}], 'status': 1}
    _this.update_device=function(received_data){
        if (received_data.status==0){
            _this.$message({
               type:"success" ,
               message:"获取用户设备列表失败"
            })
        }
        else{
            _this.did_lst=[];//存放设备列表
            _this.did_status={};//存放设备在线状态{did:状态}
            for (let i =0;i<received_data.data.length;i++){
                _this.did_lst.push(received_data.data[i].did);
                _this.did_status[received_data.data[i].did]=received_data.data[i].status;
            }
            // console.log("获取到设备列表:",_this.did_lst)
            _this.now_select_did=_this.did_lst[0];
            _this.select_deivce_id_data={
                data:_this.did_lst,
                v:_this.now_select_did,
                select_id:_this.select_id
            }
            // console.log("开始获取控制命名")
            _this.a0_a1_a0_a4_a0_refresh=_this.a0_a1_a0_a4_a0_refresh=='4'?"3":"4";//刷新组件
            //获取设备控制命令
            _this.request_7_ctrl_func();
            // console.log("_this.select_deivce_id_data",_this.select_deivce_id_data)
        } 
    }
    _this.request_2_device_func=function(){
        _this.request_2_device({
            body_data:{token:_this.token},
            execute_lst:[
                {
                    type:'func',
                    func:_this.update_device,
                    args:['received_data']
                }
            ]
        })
    }
    
    //虫情测报
    //picRecord  获取历史数据
    
_this.update_a0_a1_a0_a0_a0=function(){
        
        _this.a0_a1_a0_a0_a0_data={
            token:_this.token,
            did:_this.now_select_did
        }
        _this.a0_a1_a0_a0_a0_refresh=_this.a0_a1_a0_a0_a0_refresh=='6'?"5":"6";//刷新组件
    }
    //切换到设备控制 获取到当前设备控制的状态
//     {
//     "msg": "操作成功",
//     "data": {
//         "datetime": "2024-09-28 12:11:46",
//         "did": "AAAA402A8FB24514",
//         "op": [
//             {
//                 "groupname": "运行模式",
//                 "status": "手动"
//             },
//             {
//                 "groupname": "诱虫灯",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "吹虫风机",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "雨虫挡板",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "杀虫仓上挡板",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "杀虫仓加热",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "杀虫仓下挡板",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "烘干仓加热",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "烘干仓下挡板",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "震动装置",
//                 "status": "关闭"
//             },
//             {
//                 "groupname": "补光灯",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "摄像头",
//                 "status": "开启"
//             },
//             {
//                 "groupname": "清扫装置",
//                 "status": "开启"
//             }
//         ]
//     },
//     "status": 1
// }
    _this.update_opnow=function(received_data){
        // console.log(" 获取到当前设备控制的状态",received_data)
        if (received_data.status==0){

            _this.$message({
               type:"error" ,
               message:"获取到当前设备控制的状态失败"
            })
        }else{
        let new_dct={};
        let op_lst=received_data.data.op;
        for (let i=0;i<op_lst.length;i++){
            new_dct[op_lst[i].groupname]=op_lst[i].status;
        }
        _this.a0_a1_a0_a2_a0_data={
            status_dct:JSON.stringify(new_dct),
            cmd_dct:_this.cmd_dct,
            did:_this.now_select_did,
            token:_this.token
        }
        //刷新状态
        _this.a0_a1_a0_a2_a0_refresh=_this.a0_a1_a0_a2_a0_refresh=="10"?"9":"10";
        }
    }
    _this.request_6_opnow_func=function(){
        _this.request_6_opnow({
            body_data:{token:_this.token,
"did":_this.now_select_did,},
execute_lst:[
                {
                    type:'func',
                    func:_this.update_opnow,
                    args:['received_data']
                }
            ]
        })
    }
    //切换到设备数据 获取到温度光照降雨
    _this.update_data=function(received_data){
        // console.log(" 获取获取到温度光照降雨",received_data)
//         {
//     "msg": "操作成功",
//     "data": [
//         {
//             "datetime": "2024-09-28 12:11:49",
//             "jsonstr": "[{\"unit\":\"℃\",\"ename\":\"ins-Temp1\",\"name\":\"杀虫仓温度\",\"value\":\"41\"},{\"unit\":\"℃\",\"ename\":\"ins-Temp2\",\"name\":\"烘干仓温度\",\"value\":\"36\"},{\"unit\":\"\",\"ename\":\"ins-State\",\"name\":\"降雨状态\",\"value\":\"0\"},{\"unit\":\"Lux\",\"ename\":\"ins-light\",\"name\":\"光照度\",\"value\":\"246\"}]",
//             "did": "AAAA402A8FB24514"
//         }
//     ],
//     "status": 1
// }    
if (received_data.status=="0"){
    _this.$message({"type":"error","message":"获取设备数据失败"}
    )
}else{
    _this.a0_a1_a0_a3_a0_data={recv_str:received_data.data[0].jsonstr,"connect_status":_this.did_status[_this.now_select_did]};
    console.log("开始刷新数据:",_this.a0_a1_a0_a3_a0_data)
    _this.a0_a1_a0_a3_a0_refresh=_this.a0_a1_a0_a3_a0_refresh=="12"?"11":"12";
}
    }
    _this.request_3_data_func=function(){
        // console.log("kaishi33333")
        _this.request_3_data({
            body_data:{token:_this.token,
"did":_this.now_select_did,},
execute_lst:[
                {
                    type:'func',
                    func:_this.update_data,
                    args:['received_data']
                }
            ]
        })
    }


    _this.test_flag=false;

    if (_this.test_flag==false){
        //读取当前url问号后面的参数 username和password
        function get_url_params() {  
                // 创建一个URL对象  
                let urlObj = new URL(window.location.href);  
                // 使用URLSearchParams来解析查询字符串  
                let params = new URLSearchParams(urlObj.search);  
                // 初始化一个空对象来存储结果  
                let result = {};  
                // 遍历查询参数  
                for (let [key, value] of params.entries()) {
                    // 将查询参数添加到结果对象中  
                    result[key] = value;  
                }  
                // 返回结果对象  
                return result;  
            }
        //token为空 获取token
        if(_this.token==null){
            let params=get_url_params()
            _this.request_1_login_func(params.username,params.password)}
    }
}
},);

        // 创建Vue实例
        new Vue({
            el: '#rr',
            vuetify,
        });
    </script>
</body>
</html>
